package com.mz.ozy.activity.login;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;


import androidx.annotation.Nullable;

import com.mz.ozy.R;
import com.mz.ozy.base.BaseActivity;
import com.mz.ozy.bean.AgreementBean;
import com.mz.ozy.mvp.presenter.AgreementPresenter;
import com.mz.ozy.mvp.view.AgreementContract;
import com.mz.ozy.widget.MyWebView;

import butterknife.BindView;
import butterknife.ButterKnife;

public class AgreementActivity extends BaseActivity<AgreementContract.View, AgreementPresenter> implements AgreementContract.View {

    @BindView(R.id.webView)
    MyWebView mWebView;
    private int type;

    /**
     * @param context
     * @param type    1-用户协议  2-隐私政策
     */
    public static void go(Context context, int type) {
        Intent intent = new Intent(context, AgreementActivity.class);
        intent.putExtra("type", type);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_agreement);
        ButterKnife.bind(this);
        initTitle();
        type = getIntent().getIntExtra("type", type);
        if (type == 1) {
            tvTitle.setText(R.string.service_agreement);
        } else if (type == 2) {
            tvTitle.setText(R.string.privacy_policy);
        }
//        mPresenter.onAgreement(this, type + "");
    }

    @Override
    public void onAgreementSuccess(AgreementBean bean) {
        if(bean.getMap()!=null){
            mWebView.loadData(bean.getMap().getContent());
        }
    }
}
